<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript" >
  <!--
	var menuTree;
	var mainIframe;
	var setting = {
		view: {
			dblClickExpand: false,
			showLine: true,
			selectedMulti: false,
			expandSpeed: ($.browser.msie && parseInt($.browser.version)<=6)?"":"fast"
		},
		data: {
			simpleData: {
				enable:true,
				idKey: "id",
				pIdKey: "pId",
				rootPId: ""
			}
		},
		callback: {
			beforeClick: function(treeId, treeNode) {
				if (treeNode.isParent) {
					menuTree.expandNode(treeNode);
					return false;
				} else {
					mainIframe.attr("src", treeNode.fromAction);
					return true;
				}
			}
		}
	};

	var menuTreeNodes = <%=session.getAttribute("menuTree") %>;

	$(document).ready(function(){
		menuTree = $.fn.zTree.init($("#menuTree"), setting, menuTreeNodes);
		menuTree.expandAll(true);
		mainIframe = $("#mainIframe");
		mainIframe.bind("load", loadReady);
	});

	function loadReady() {
		var pH = document.body.clientHeight - 10;
		mainIframe.height(pH);
		/*
		var bodyH = mainIframe.contents().find("body").get(0).scrollHeight;
		var htmlH = mainIframe.contents().find("html").get(0).scrollHeight;
		var maxH = Math.max(bodyH, htmlH);
		var minH = Math.min(bodyH, htmlH);
		var h = mainIframe.height() >= maxH ? minH : maxH;
		if (h < pH){
			h = pH;
		}
		mainIframe.height(h);
		*/
	}
  //-->
  </script>
</head>
<body>
	<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="200" style="border-right: solid 2px #9ad452;" valign="top">
				<ul id="menuTree" class="ztree" style="width:100%; height:100%; overflow:auto;"></ul>
			<td>
				<iframe id="mainIframe" name="mainIframe" frameborder="0" height="100%" width="100%" onload="loadReady();" ></iframe>
			</td>
		</tr>
	</table>
</body>
</html>
